package demo.demo07.test02;

//守护线程
public class testDaemon {

    public static void main(String[] args) {
        God god = new God();
        You1 you1 = new You1();

        Thread thread = new Thread(god);
        thread.setDaemon(true);//默认false表示用户线程，正常的线程都是用户线程。
        thread.start();//上帝守护线程启动
        new Thread(you1).start();//被守护线程启动
    }
}
//上帝

class God implements Runnable {

    @Override
    public void run() {
        while (true) {
            System.out.println("保佑你");
        }
    }
}


//你
class You1 implements Runnable {

    @Override
    public void run() {
        for (int i = 0; i < 36500; i++) {
            System.out.println("活着");
        }
        System.out.println("再见");
    }
}